const { HTTP } = require('../../utils/http');
const { api } = require('../../utils/api');
const { request } = new HTTP();

const app = getApp()

Page({
  data: {
    sex: 1,
    answers: []
  },
  onShow(){
  },
  onLoad() {
    this._getAnswer();
  },
  async _getAnswer() {
    let {returnCode = '', beans = []} = await request({
      url: api.getAnswer,
      method: 'get',
      data: {}
    });
    if (returnCode === '0000') {
      this.setData({
        answers: beans
      });
    }
  },
  addOrEdit(event) {
    const { currentTarget: { dataset } } = event;
    if (dataset.bean) {
      const url = true
                  ? `../editAnswer/index?id=${dataset.bean.id}&title=${encodeURIComponent(dataset.bean.question)}&lastValue=${encodeURIComponent('sdfhsd大煞风景卡首付款几十块')}`
                  : `../editAnswer/index?id=${dataset.bean.id}&title=${encodeURIComponent(dataset.bean.question)}`;
      wx.navigateTo({url});
    }

  }
})
